import { animation } from "@/utils";
import { request } from "@/utils/request";
import { View, Button, Textarea } from "@tarojs/components";
import Taro from "@tarojs/taro";
import { useState } from "react";

export default function Index() {
  const [percent, setPercent] = useState(0);
  const [content, setContent] = useState("");

  const onFilish = async () => {
    // Taro.getLocation({
    //   type: "wgs84",
    //   success: function (res) {
    //     console.log(res);
    //   },
    // });

    // if (!content) {
    //   Taro.showToast({ title: "请输入报告内容" });
    //   return;
    // }
    // animation({
    //   from: 0,
    //   to: 100,
    //   duration: 600,
    //   onUpdate(v) {
    //     setPercent(parseFloat(v.toFixed(2)));
    //   },
    //   onEnd() {
    //     console.log(content);
    //     Taro.showToast({ title: "报告成功" });
    //     setContent("");
    //   },
    // });

    const ret = await request({ method: "GET", url: "/" });
    console.log(ret);
  };

  return (
    <>
      {percent > 0 && percent < 100 && (
        <View
          className="h-[2px] bg-green-600 absolute"
          style={{ width: percent + "%" }}
        />
      )}
      <View className="p-4">
        <View className="text-sm text-gray-500">
          如有发现数据有错误的地方，请提交内容，我们感谢你的勘误。
        </View>
        <View className="border p-2 border-gray-300 rounded-lg mt-2">
          <Textarea
            value={content}
            onInput={(e) => {
              setContent(e.detail.value);
            }}
          />
        </View>
        <Button type="primary" className="mt-2" onClick={onFilish}>
          提交
        </Button>
      </View>
    </>
  );
}
